package com.wflow.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wflow.bean.do_.DeptDo;
import com.wflow.bean.entity.WflowUserDepartments;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author : willian fu
 * @date : 2022/6/27
 */
public interface WflowUserDepartmentsMapper extends BaseMapper<WflowUserDepartments> {

    /**
     * 查询指定用户所在的部门，一个用户可能同时在多个部门下
     * @param userId 用户ID
     * @return 用户所在的部门列表
     */
    @Select("SELECT wd.id, wd.dept_name FROM wflow_user_departments wud, wflow_departments wd WHERE wud.dept_id = wd.id AND wud.user_id = #{userId}")
    List<DeptDo> getUserDepts(@Param("userId") String userId);
}
